﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PHMEE.Admin.Application.Contracts.IServices.DaqInfo.WaveIntervals;
using PHMEE.Admin.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;

namespace PHMEE.Admin.HttpApi.Controllers.DaqInfo.WaveIntervals
{
    /// <summary>
    /// 波形/指标间隔模块
    /// </summary>
    [Route("phmeeadmin/api/[controller]/[action]")]
    public class WaveIntervalController : PHMEEAdminController
    {
        private readonly IWaveIntervalAppSerive _waveIntervalAppSerive;

        public WaveIntervalController(IWaveIntervalAppSerive waveIntervalAppSerive)
        {
            _waveIntervalAppSerive = waveIntervalAppSerive;
        }
        /// <summary>
        /// 根据id查询波形，指标间隔
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<WaveIntervalDto> GetWaveIntervarlById(Guid id)
        {
            return await _waveIntervalAppSerive.GetByIdAsync(id);
        }
        /// <summary>
        /// 根据间隔类型查询
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetWaveIntervarlByType(IntervalStyle type)
        {
            List<WaveIntervalDto> WaveIntervallist = await _waveIntervalAppSerive.GetByTypeAsync(type);

            return Ok(new { message = "success", items = WaveIntervallist });
        }
        /// <summary>
        /// 查询 波形/指标间隔-可分页排序
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<PagedResultDto<WaveIntervalDto>> GetPagedWaveInterval(PageWaveIntevalDto input)
        {
            return await _waveIntervalAppSerive.GetPagedAsync(input);
        }
        /// <summary>
        /// 创建 波形/指标间隔
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<WaveIntervalDto> CreateWaveInterval(CreateWaveIntervalDto input)
        {
            return await _waveIntervalAppSerive.CreateAsync(input);
        }
        /// <summary>
        /// 编辑 波形/指标间隔
        /// </summary>
        /// <param name="id"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateWaveInterval(UpdateWaveIntervalDto input)
        {
            await _waveIntervalAppSerive.UpdateAsync(input.Id, input);
            return Ok(new { Message = "Success" });
        }
        /// <summary>
        /// 删除 波形/指标间隔
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteWaveInterval(Guid id)
        {
            await _waveIntervalAppSerive.DeleteAsync(id);
            return Ok(new { Message = "Success" });
        }
    }
}
